package com.yyfax.infrastructure.network.entity;

import com.google.gson.Gson;
import com.yyfax.infrastructure.mvp.ResponseCode;

public class BaseResultEntity<T> {
	public int requestCode;
	public Object extraParam;//需要返回的请求参数
	public String requestPage;//发送请求的页面

	private String retCode;
	private String retMsg;
	private T data;

	public String getRetCode() {
		return retCode;
	}

	public void setRetCode(String retCode) {
		this.retCode = retCode;
	}

	public String getRetMsg() {
		return retMsg;
	}

	public void setRetMsg(String retMsg) {
		this.retMsg = retMsg;
	}

	public T getData() {
		return data;
	}

	public void setData(T data) {
		this.data = data;
	}

	public String toString() {
		Gson gson = new Gson();
		String str = gson.toJson(this);
		return str;
	}

	/**
	 * 请求是否成功
	 */
	public static boolean isResponseSuccess(BaseResultEntity rs) {
		return ResponseCode.CODE_SUCCESS.equalsIgnoreCase(rs.getRetCode());
	}

	/**
	 * 登录超时，需重新登录
	 */
	public static boolean isResponseLogout(BaseResultEntity rs) {
		return ResponseCode.CODE_LOGOUT.equalsIgnoreCase(rs.getRetCode());
	}

}
